//
//  UtilityTests.swift
//  UtilityTests
//
//  Created by 于虎拴 on 2022/10/13.
//

import XCTest
@testable import Utility

final class UtilityTests: XCTestCase {
  
  override func setUpWithError() throws {
    // Put setup code here. This method is called before the invocation of each test method in the class.
  }
  
  override func tearDownWithError() throws {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
  }
  
  func testExample() throws {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
    // Any test you write for XCTest can be annotated as throws and async.
    // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
    // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
  }
  
  func testColor() throws {
    XCTAssertTrue(UIColor.white.hexString == "#FFFFFF", "white")
    XCTAssertTrue(UIColor.black.hexString == "#000000", "black")
    
    for i in 0...255 {
      let num = String(format: "%03D", i)
      let hex = String(format: "%02X", i)
      
      let colorHex = "#\(hex)0000"
      let color = UIColor(colorHex)
      
      XCTAssertTrue(color.hexString == colorHex, "\(num) Color:\(colorHex) != \(color.hexString)")
    }
  }
  
  func testPerformanceExample() throws {
    // This is an example of a performance test case.
    self.measure {
      // Put the code you want to measure the time of here.
    }
  }
  
}
